using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

namespace shfa.snomtastic.data
{
    public partial class SqlDataProvider
    {

        public Guid InsertConfigurationSetting(Guid configurationId, Guid settingId, bool active, string permissionFlag, string value, string pattern, string replacement)
		{
            return new Guid(Convert.ToString(SqlHelper.ExecuteScalar(ConnectionString, "sp_ConfigurationSettingInsert", GetNull(configurationId), GetNull(settingId), active, permissionFlag, value, pattern, replacement)));
		}

        public int UpdateConfigurationSetting(Guid configurationId, Guid settingId, bool active, string permissionFlag, string value, string pattern, string replacement)
		{
            return Convert.ToInt32(SqlHelper.ExecuteScalar(ConnectionString, "sp_ConfigurationSettingUpdate", GetNull(configurationId), GetNull(settingId), active, permissionFlag, value, pattern, replacement));
		}

        public int DeleteConfigurationSetting(Guid configurationId, Guid settingId) 
		{
            return Convert.ToInt32(SqlHelper.ExecuteScalar(ConnectionString, "sp_ConfigurationSettingDelete", configurationId, settingId));
		}

        public DataRow SelectConfigurationSetting(Guid configurationId, Guid settingId) 
        {    
			DataSet ds = SqlHelper.ExecuteDataset(ConnectionString, "sp_ConfigurationSettingSelect", configurationId, settingId);
            if (ds.Tables.Count > 0)
                if (ds.Tables[0].Rows.Count > 0)
                    return ds.Tables[0].Rows[0];

            return null;
		}

		public DataTable SelectConfigurationSettings() 
		{
            return SqlHelper.ExecuteDataset(ConnectionString, "sp_ConfigurationSettingSelectAll").Tables[0];
        }

		public DataTable SelectConfigurationSettingsByConfiguration(Guid configurationId) 
		{
            return SqlHelper.ExecuteDataset(ConnectionString, "sp_ConfigurationSettingSelectByConfiguration", configurationId).Tables[0];
        }

		public DataTable SelectConfigurationSettingsBySetting(Guid settingId) 
		{
            return SqlHelper.ExecuteDataset(ConnectionString, "sp_ConfigurationSettingSelectBySetting", settingId).Tables[0];
        }

    }

}
